package day006.api_gui.itheima03;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class CaseListener {
    public static void main(String[] args) {
        JFrame jf = new JFrame();
        jf.setTitle("时间监听机制");
        jf.setSize(400, 300);
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jf.setLocationRelativeTo(null); // 将窗口居中
        jf.setLayout(null);
        jf.setAlwaysOnTop(true);

        JButton jb = new JButton("你点我啊！");
        jb.setBounds(0, 0, 100, 100);
        jf.add(jb);

        jb.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("你点我啊！");
            }
        });

        jf.setVisible(true);
    }
}
